package com.timber.util;

import java.util.Vector;

import com.timber.tableModels.InvColumnManager;

public class ItemMgrTableModel extends SLTableModel  {
	
	
	protected static Vector			v = new Vector();
	protected static ColumnSortDescriptor[]	defaultSortCols;
	private static final long serialVersionUID = 1L;
	
	static
	{
		cm = new InvColumnManager();
		v.add( cm.getByIdClone( InvColumnManager.ITEM_ID ) );
		v.add( cm.getByIdClone( InvColumnManager.TIMBER_NAME  ) );
		v.add( cm.getByIdClone( InvColumnManager.TIMBER_CLASS  ) );
		v.add( cm.getByIdClone( InvColumnManager.TIMBER_LENGTH  ) );
		v.add( cm.getByIdClone( InvColumnManager.TIMBER_WIDTH  ) );		
		v.add( cm.getByIdClone( InvColumnManager.QUANTITY  ) );
		v.add( cm.getByIdClone( InvColumnManager.MEASURMENT  ) );
		v.add( cm.getByIdClone( InvColumnManager.UNITS  ) );
		v.add( cm.getByIdClone( InvColumnManager.PURCHASE_PRICE  ) );
		v.add( cm.getByIdClone( InvColumnManager.SALESPRICE  ) );
		v.add( cm.getByIdClone( InvColumnManager.PROFITMARGIN  ) );
		v.add( cm.getByIdClone( InvColumnManager.TAX ) );
		v.add( cm.getByIdClone( InvColumnManager.AMOUNT ) );
		v.add( cm.getByIdClone( InvColumnManager.LOTNUMBER ) );
		v.add( cm.getByIdClone( InvColumnManager.LOCATION ) );
		v.add( cm.getByIdClone( InvColumnManager.PURCHASEDFROM ) );
		v.add( cm.getByIdClone( InvColumnManager.PURCHASEDATE ) );
		v.add( cm.getByIdClone( InvColumnManager.COMPANYNAME ) );
	}
	
	public Object getFieldAt(Object obj, int c) {
		
		Object ret = null;
		
		if( obj != null )
		{
			int id = getColumnId( c );	
			IteamBean item = (IteamBean)obj;
			switch(id)
			{
			
			case InvColumnManager.ITEM_ID:
				ret =item.getItemCode();			
			break;
			case InvColumnManager.TIMBER_NAME:
				ret =item.getItemName();			
			break;
			
			case InvColumnManager.TIMBER_CLASS:
				ret =item.getItemClass();			
			break;
			
			case InvColumnManager.TIMBER_LENGTH:
				
				ret =new Double( item.getLength());
			
			break;
			case InvColumnManager.TIMBER_WIDTH:
				
				ret =new Double(item.getWidth());
			
			break;
			
			case InvColumnManager.QUANTITY:
				
				ret =new Double(item.getQuantity());
			
			break;
			case InvColumnManager.MEASURMENT:
				
				ret =item.getMeasurement();
			
			break;
			case InvColumnManager.PURCHASE_PRICE:
				
				ret =new Double(item.getPurchasePrice());
			
			break;
			case InvColumnManager.SALESPRICE:
				
				ret =new Double(item.getSalesPrice());
			
			break;
			case InvColumnManager.PROFITMARGIN:
				
				ret =new Double(item.getProfitMargin());
			
			break;
			
			
			case InvColumnManager.TAX:
				
				ret =new Double(item.getTax());
			
			break;
			
			case InvColumnManager.AMOUNT:
				
				ret =new Double(item.getAmount());
			
			break;
			case InvColumnManager.LOTNUMBER:
				
				ret =item.getLotNumber();
			
			break;
			
		
			case InvColumnManager.UNITS:
				
				ret =new Double(item.getUnits());
			
			break;
			
			
			case InvColumnManager.PURCHASEDFROM:
				
				ret =item.getPurchasedFrom();
			
			break;
			
			case InvColumnManager.LOCATION:
				
				ret =item.getLocation();
			
			break;
			
			
			case InvColumnManager.PURCHASEDATE:
				
				ret =item.getPurchasedDate();
			
			break;
			
			
			case InvColumnManager.COMPANYNAME:
				
				ret =item.getCompanyName();
			
			break;
			
			
			
			
			}
			
		}
		
		return ret;
	}
	
	public ItemMgrTableModel()
	{
		super( 0, v );
		// setDefaultSortCols( defaultSortCols );
		//setAlterBgOnSort();
	}
	
	public ItemMgrTableModel( Vector dataVector )
	{
		super( dataVector, v );
		// setDefaultSortCols( defaultSortCols );
		// setAlterBgOnSort();
	}
	
	
}
